package com.kun.companion.core.util;

import javafx.application.Platform;

import java.awt.*;

/**
 * TODO
 *
 * @author gzc
 * @since 2025/1/26 18:58
 **/
public class ComUtil {
    /**
     * 显示器尺寸信息
     */
    public static final Toolkit TOOLKIT = Toolkit.getDefaultToolkit();
    public static final Dimension DIMENSION = TOOLKIT.getScreenSize();
    public static final DisplayMode DISPLAY_MODE = GraphicsEnvironment.getLocalGraphicsEnvironment().getScreenDevices()[0].getDisplayMode();

    /**
     * 主线程执行
     *
     * @param runnable 需要执行的函数
     */
    public static void uiThreadRun(Runnable runnable) {
        if (Platform.isFxApplicationThread()) {
            runnable.run();
        } else {
            Platform.runLater(runnable);
        }
    }

}
